package com.health.controller;

import com.health.common.constant.MessageConstant;
import com.health.common.entity.OrderSetup;
import com.health.common.vo.RespBean;
import com.health.service.OrderSetupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/orderSetup")
public class OrderSetupController {

    @Autowired
    private OrderSetupService orderSetupService;

    @GetMapping("/getOrderSetupByMonth")
    public RespBean getOrderSetupByMonth(String month){
        RespBean respBean = RespBean.build();
        List<Map<String,Object>> list = orderSetupService.getOrderSetupByMonth(month);
        if(list.size() > 0){
            respBean.setObj(list);
            respBean.setStatus(200);
            respBean.setMessage(MessageConstant.GET_ORDERSETTING_SUCCESS);
            return respBean;
        }else{
            respBean.setStatus(500);
            respBean.setMessage(MessageConstant.GET_ORDERSETTING_FAIL);
            return respBean;
        }
    }

    @PostMapping("/editNumberByOrderDate")
    public RespBean editNumberByOrderDate(@RequestBody OrderSetup orderSetup){
        if(orderSetupService.editNumberByOrderDate(orderSetup) == 1){
            return RespBean.ok("修改预约人数成功");
        }
        return RespBean.error("修改预约人数失败");
    }

}
